package com.codi.bus.util;

import com.google.common.base.Strings;
import lombok.extern.slf4j.Slf4j;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 模块名
 *
 * @author spy
 * @version 1.0 2018-01-09 14:59
 * @since 1.0
 */
@Slf4j
public class NumberUtil {

    private static Pattern patternMobile = Pattern.compile("^1[3|5|7|8][0-9]{9}$");
    public static String formatNumber(String numberStr) {
        if (Strings.isNullOrEmpty(numberStr)) {
            return null;
        }

        return numberStr.replaceAll("\\,", "");
    }

    /**
     * 验证手机号码的格式是否正确
     *
     * @param mobileString
     * @return
     */
    public static boolean isMobilePhoneVerify(String mobileString) {
        if (mobileString == null || "".equals(mobileString.trim())) {
            return false;
        } else {
            String mobileTrim = mobileString.trim();
            Matcher matcherMobile = patternMobile.matcher(mobileTrim);
            return matcherMobile.matches();
        }
    }
}
